package com.ferry.transport.netty.client;

import com.ferry.registry.domain.registry.RegistryMetaData;
import com.ferry.registry.listener.NotifyListener;
import com.ferry.registry.listener.OfflineListener;
import com.ferry.registry.service.IRegistryService;
import com.ferry.transport.api.Connection;
import com.ferry.transport.api.Directory;
import com.ferry.transport.api.UnResolvedAddress;
import com.ferry.transport.netty.consumer.ConnectionWatcher;
import com.ferry.transport.netty.consumer.Connector;

import java.util.List;

/**
 * Created by daiyong
 */
public interface ConsumerClient {

	String appName();  //应用名称

	/**
	 * 连接器
	 * @return
	 */
	Connector<Connection> connector();

	/**
	 * 设置连接器
	 * @param connector
	 */
	void setConnector(Connector<Connection> connector);

	IRegistryService registryService();

	/**
	 * 查找服务
	 * @param directory
	 * @return
	 */
	List<RegistryMetaData> lookup(Directory directory);

	ConnectionWatcher watchConnections(Class<?> interfaceClass);

	ConnectionWatcher watchConnections(Class<?> interfaceClass, String version);

	ConnectionWatcher watchConnections(Directory directory);

	boolean awaitConnections(Class<?> interfaceClass, long timeoutMillis);

	boolean awaitConnections(Class<?> interfaceClass, String version, long timeoutMillis);

	boolean awaitConnections(Directory directory, long timeoutMillis);

	void subscribe(Directory directory, NotifyListener listener);

	void offlineListening(UnResolvedAddress address, OfflineListener listener);

	void shutdownGracefully();

}
